<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>ol/style/Style【译】 | lovewhoilove 的小站</title><meta name="author" content="lovewhoilove"><meta name="copyright" content="lovewhoilove"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="原文链接及内容原文链接：https:&#x2F;&#x2F;openlayers.org&#x2F;en&#x2F;latest&#x2F;apidoc&#x2F;module-ol_style_Style-Style.html   ol&#x2F;style&#x2F;Style~Style1import Style from &amp;#x27;ol&#x2F;style&#x2F;Style.js&amp;#x27;; Style 是矢量要素渲染样式的容器。需要注意的是，使用该样式的要">
<meta property="og:type" content="article">
<meta property="og:title" content="ol&#x2F;style&#x2F;Style【译】">
<meta property="og:url" content="https://lovewhoilove.gitee.io/posts/965064e3/">
<meta property="og:site_name" content="lovewhoilove 的小站">
<meta property="og:description" content="原文链接及内容原文链接：https:&#x2F;&#x2F;openlayers.org&#x2F;en&#x2F;latest&#x2F;apidoc&#x2F;module-ol_style_Style-Style.html   ol&#x2F;style&#x2F;Style~Style1import Style from &amp;#x27;ol&#x2F;style&#x2F;Style.js&amp;#x27;; Style 是矢量要素渲染样式的容器。需要注意的是，使用该样式的要">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://u-1303826255.cos.ap-nanjing.myqcloud.com/openlayers/202403232115680.png?imageMogr2/quality/75/format/webp/interlace/0">
<meta property="article:published_time" content="2024-03-23T12:42:29.000Z">
<meta property="article:modified_time" content="2024-04-01T03:50:23.439Z">
<meta property="article:author" content="lovewhoilove">
<meta property="article:tag" content="Openlayers API">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://u-1303826255.cos.ap-nanjing.myqcloud.com/openlayers/202403232115680.png?imageMogr2/quality/75/format/webp/interlace/0"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://lovewhoilove.gitee.io/posts/965064e3/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="manifest" href="/img/pwa/manifest.json"/><meta name="msapplication-TileColor" content="#49b1f5"/><link rel="apple-touch-icon" sizes="180x180" href="/img/pwa/apple-touch-icon.png"/><link rel="icon" type="image/png" sizes="32x32" href="/img/pwa/32.png"/><link rel="icon" type="image/png" sizes="16x16" href="/img/pwa/16.png"/><link rel="mask-icon" href="/img/pwa/32.png" color="#5bbad5"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":false,"languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: {"limitCount":50,"languages":{"author":"作者: lovewhoilove","link":"链接: ","source":"来源: lovewhoilove 的小站","info":"著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"}},
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: true,
  islazyload: true,
  isAnchor: false,
  percent: {
    toc: false,
    rightside: true,
  }
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'ol/style/Style【译】',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2024-04-01 11:50:23'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="/css/progress_bar.css"><link rel="stylesheet" href="/css/custom.css"><svg aria-hidden="true" style="position:absolute; overflow:hidden; width:0; height:0"><symbol id="icon-sun" viewBox="0 0 1024 1024"><path d="M960 512l-128 128v192h-192l-128 128-128-128H192v-192l-128-128 128-128V192h192l128-128 128 128h192v192z" fill="#FFD878" p-id="8420"></path><path d="M736 512a224 224 0 1 0-448 0 224 224 0 1 0 448 0z" fill="#FFE4A9" p-id="8421"></path><path d="M512 109.248L626.752 224H800v173.248L914.752 512 800 626.752V800h-173.248L512 914.752 397.248 800H224v-173.248L109.248 512 224 397.248V224h173.248L512 109.248M512 64l-128 128H192v192l-128 128 128 128v192h192l128 128 128-128h192v-192l128-128-128-128V192h-192l-128-128z" fill="#4D5152" p-id="8422"></path><path d="M512 320c105.888 0 192 86.112 192 192s-86.112 192-192 192-192-86.112-192-192 86.112-192 192-192m0-32a224 224 0 1 0 0 448 224 224 0 0 0 0-448z" fill="#4D5152" p-id="8423"></path></symbol><symbol id="icon-moon" viewBox="0 0 1024 1024"><path d="M611.370667 167.082667a445.013333 445.013333 0 0 1-38.4 161.834666 477.824 477.824 0 0 1-244.736 244.394667 445.141333 445.141333 0 0 1-161.109334 38.058667 85.077333 85.077333 0 0 0-65.066666 135.722666A462.08 462.08 0 1 0 747.093333 102.058667a85.077333 85.077333 0 0 0-135.722666 65.024z" fill="#FFB531" p-id="11345"></path><path d="M329.728 274.133333l35.157333-35.157333a21.333333 21.333333 0 1 0-30.165333-30.165333l-35.157333 35.157333-35.114667-35.157333a21.333333 21.333333 0 0 0-30.165333 30.165333l35.114666 35.157333-35.114666 35.157334a21.333333 21.333333 0 1 0 30.165333 30.165333l35.114667-35.157333 35.157333 35.157333a21.333333 21.333333 0 1 0 30.165333-30.165333z" fill="#030835" p-id="11346"></path></symbol></svg><!-- hexo injector head_end start --><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-wowjs/lib/animate.min.css" media="print" onload="this.media='screen'"><!-- hexo injector head_end end --><meta name="generator" content="Hexo 5.4.2"></head><body><div id="loading-box" onclick="document.getElementById(&quot;loading-box&quot;).classList.add(&quot;loaded&quot;)"><div class="loading-bg"><div class="loading-img"></div><div class="loading-image-dot"></div></div></div><script>const preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',()=> { preloader.endLoading() })

if (true) {
  document.addEventListener('pjax:send', () => { preloader.initLoading() })
  document.addEventListener('pjax:complete', () => { preloader.endLoading() })
}</script><link rel="stylesheet" href="/css/custom.css"/><script src="https://cdn.jsdelivr.net/npm/pace-js/pace.min.js"></script><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/img/avatar.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">250</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">327</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">2</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-newspaper"></i><span> 文章相关</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/archives/"><i class="fa-fw fas fa-timeline"></i><span> 时间轴</span></a></li><li><a class="site-page child" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></li></ul></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-layer-group"></i><span> Openlayers</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/doc/"><i class="fa-fw fas fa-book-reader"></i><span> 说明文档</span></a></li><li><a class="site-page child" href="/quick-start/"><i class="fa-fw fas fa-bolt"></i><span> 快速入门</span></a></li><li><a class="site-page child" href="/tutorials/"><i class="fa-fw fas fa-book"></i><span> 教程</span></a></li><li><a class="site-page child" href="/faq/"><i class="fa-fw fas fa-question"></i><span> 常见问题</span></a></li><li><a class="site-page child" href="/workshop/"><i class="fa-fw fas fa-graduation-cap"></i><span> 研讨会</span></a></li><li><a class="site-page child" href="/examples/"><i class="fa-fw fas fa-laptop-code"></i><span> 示例</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 网址导航</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://u-1303826255.cos.ap-nanjing.myqcloud.com/openlayers/202403232115680.png?imageMogr2/quality/75/format/webp/interlace/0')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">lovewhoilove 的小站</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-newspaper"></i><span> 文章相关</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/archives/"><i class="fa-fw fas fa-timeline"></i><span> 时间轴</span></a></li><li><a class="site-page child" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></li></ul></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-layer-group"></i><span> Openlayers</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/doc/"><i class="fa-fw fas fa-book-reader"></i><span> 说明文档</span></a></li><li><a class="site-page child" href="/quick-start/"><i class="fa-fw fas fa-bolt"></i><span> 快速入门</span></a></li><li><a class="site-page child" href="/tutorials/"><i class="fa-fw fas fa-book"></i><span> 教程</span></a></li><li><a class="site-page child" href="/faq/"><i class="fa-fw fas fa-question"></i><span> 常见问题</span></a></li><li><a class="site-page child" href="/workshop/"><i class="fa-fw fas fa-graduation-cap"></i><span> 研讨会</span></a></li><li><a class="site-page child" href="/examples/"><i class="fa-fw fas fa-laptop-code"></i><span> 示例</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 网址导航</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">ol/style/Style【译】</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2024-03-23T12:42:29.000Z" title="发表于 2024-03-23 20:42:29">2024-03-23</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2024-04-01T03:50:23.439Z" title="更新于 2024-04-01 11:50:23">2024-04-01</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/Openlayers/">Openlayers</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">1.1k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>4分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="ol/style/Style【译】"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div><img class="nolazyload" id="post-top-bg" src="background-image: url('https://u-1303826255.cos.ap-nanjing.myqcloud.com/openlayers/202403232115680.png?imageMogr2/quality/75/format/webp/interlace/0')"></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><details class="toggle" style="border: 1px solid black"><summary class="toggle-button" style="background-color: black;color: #fff">原文链接及内容</summary><div class="toggle-content"><p>原文链接：<a target="_blank" rel="noopener" href="https://openlayers.org/en/latest/apidoc/module-ol_style_Style-Style.html">https://openlayers.org/en/latest/apidoc/module-ol_style_Style-Style.html</a></p>
<iframe src="https://openlayers.org/en/latest/apidoc/module-ol_style_Style-Style.html" width="100%" height="400px" frameborder="0" loading="lazy" allowfullscreen></iframe></div></details>

<h2 id="ol-x2F-style-x2F-Style-Style"><a href="#ol-x2F-style-x2F-Style-Style" class="headerlink" title="ol&#x2F;style&#x2F;Style~Style"></a>ol&#x2F;style&#x2F;Style~Style</h2><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> <span class="title class_">Style</span> <span class="keyword">from</span> <span class="string">&#x27;ol/style/Style.js&#x27;</span>;</span><br></pre></td></tr></table></figure>
<p><code>Style</code> 是矢量要素渲染样式的容器。需要注意的是，<u>使用该样式的要素或图层，在通过<code>set*()</code>方法对样式或其子级所做的任何更改，在要素或图层重新渲染之前都不会立即生效</u>。</p>
<h2 id="默认样式"><a href="#默认样式" class="headerlink" title="默认样式"></a>默认样式</h2><p>如果没有为要素定义样式，则会使用以下默认样式：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">mport &#123;<span class="title class_">Circle</span>, <span class="title class_">Fill</span>, <span class="title class_">Stroke</span>, <span class="title class_">Style</span>&#125; <span class="keyword">from</span> <span class="string">&#x27;ol/style.js&#x27;</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> fill = <span class="keyword">new</span> <span class="title class_">Fill</span>(&#123;</span><br><span class="line">  <span class="attr">color</span>: <span class="string">&#x27;rgba(255,255,255,0.4)&#x27;</span>,</span><br><span class="line">&#125;);</span><br><span class="line"><span class="keyword">const</span> stroke = <span class="keyword">new</span> <span class="title class_">Stroke</span>(&#123;</span><br><span class="line">  <span class="attr">color</span>: <span class="string">&#x27;#3399CC&#x27;</span>,</span><br><span class="line">  <span class="attr">width</span>: <span class="number">1.25</span>,</span><br><span class="line">&#125;);</span><br><span class="line"><span class="keyword">const</span> styles = [</span><br><span class="line">  <span class="keyword">new</span> <span class="title class_">Style</span>(&#123;</span><br><span class="line">    <span class="attr">image</span>: <span class="keyword">new</span> <span class="title class_">Circle</span>(&#123;</span><br><span class="line">      <span class="attr">fill</span>: fill,</span><br><span class="line">      <span class="attr">stroke</span>: stroke,</span><br><span class="line">      <span class="attr">radius</span>: <span class="number">5</span>,</span><br><span class="line">    &#125;),</span><br><span class="line">    <span class="attr">fill</span>: fill,</span><br><span class="line">    <span class="attr">stroke</span>: stroke,</span><br><span class="line">  &#125;),</span><br><span class="line">];</span><br></pre></td></tr></table></figure>
<p>编辑的默认样式如下所示：</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> &#123; <span class="title class_">Circle</span>, <span class="title class_">Fill</span>, <span class="title class_">Stroke</span>, <span class="title class_">Style</span> &#125; <span class="keyword">from</span> <span class="string">&#x27;ol/style.js&#x27;</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> styles = &#123;&#125;;</span><br><span class="line"><span class="keyword">const</span> white = [<span class="number">255</span>, <span class="number">255</span>, <span class="number">255</span>, <span class="number">1</span>];</span><br><span class="line"><span class="keyword">const</span> blue = [<span class="number">0</span>, <span class="number">153</span>, <span class="number">255</span>, <span class="number">1</span>];</span><br><span class="line"><span class="keyword">const</span> width = <span class="number">3</span>;</span><br><span class="line">styles[<span class="string">&#x27;Polygon&#x27;</span>] = [</span><br><span class="line">  <span class="keyword">new</span> <span class="title class_">Style</span>(&#123;</span><br><span class="line">    <span class="attr">fill</span>: <span class="keyword">new</span> <span class="title class_">Fill</span>(&#123;</span><br><span class="line">      <span class="attr">color</span>: [<span class="number">255</span>, <span class="number">255</span>, <span class="number">255</span>, <span class="number">0.5</span>],</span><br><span class="line">    &#125;),</span><br><span class="line">  &#125;),</span><br><span class="line">];</span><br><span class="line">styles[<span class="string">&#x27;MultiPolygon&#x27;</span>] =</span><br><span class="line">  styles[<span class="string">&#x27;Polygon&#x27;</span>];</span><br><span class="line">styles[<span class="string">&#x27;LineString&#x27;</span>] = [</span><br><span class="line">  <span class="keyword">new</span> <span class="title class_">Style</span>(&#123;</span><br><span class="line">    <span class="attr">stroke</span>: <span class="keyword">new</span> <span class="title class_">Stroke</span>(&#123;</span><br><span class="line">      <span class="attr">color</span>: white,</span><br><span class="line">      <span class="attr">width</span>: width + <span class="number">2</span>,</span><br><span class="line">    &#125;),</span><br><span class="line">  &#125;),</span><br><span class="line">  <span class="keyword">new</span> <span class="title class_">Style</span>(&#123;</span><br><span class="line">    <span class="attr">stroke</span>: <span class="keyword">new</span> <span class="title class_">Stroke</span>(&#123;</span><br><span class="line">      <span class="attr">color</span>: blue,</span><br><span class="line">      <span class="attr">width</span>: width,</span><br><span class="line">    &#125;),</span><br><span class="line">  &#125;),</span><br><span class="line">];</span><br><span class="line">styles[<span class="string">&#x27;MultiLineString&#x27;</span>] = styles[<span class="string">&#x27;LineString&#x27;</span>];</span><br><span class="line"></span><br><span class="line">styles[<span class="string">&#x27;Circle&#x27;</span>] = styles[<span class="string">&#x27;Polygon&#x27;</span>].<span class="title function_">concat</span>(</span><br><span class="line">  styles[<span class="string">&#x27;LineString&#x27;</span>]</span><br><span class="line">);</span><br><span class="line"></span><br><span class="line">styles[<span class="string">&#x27;Point&#x27;</span>] = [</span><br><span class="line">  <span class="keyword">new</span> <span class="title class_">Style</span>(&#123;</span><br><span class="line">    <span class="attr">image</span>: <span class="keyword">new</span> <span class="title class_">Circle</span>(&#123;</span><br><span class="line">      <span class="attr">radius</span>: width * <span class="number">2</span>,</span><br><span class="line">      <span class="attr">fill</span>: <span class="keyword">new</span> <span class="title class_">Fill</span>(&#123;</span><br><span class="line">        <span class="attr">color</span>: blue,</span><br><span class="line">      &#125;),</span><br><span class="line">      <span class="attr">stroke</span>: <span class="keyword">new</span> <span class="title class_">Stroke</span>(&#123;</span><br><span class="line">        <span class="attr">color</span>: white,</span><br><span class="line">        <span class="attr">width</span>: width / <span class="number">2</span>,</span><br><span class="line">      &#125;),</span><br><span class="line">    &#125;),</span><br><span class="line">    <span class="attr">zIndex</span>: <span class="title class_">Infinity</span>,</span><br><span class="line">  &#125;),</span><br><span class="line">];</span><br><span class="line">styles[<span class="string">&#x27;MultiPoint&#x27;</span>] = styles[<span class="string">&#x27;Point&#x27;</span>];</span><br><span class="line">styles[<span class="string">&#x27;GeometryCollection&#x27;</span>] = styles[<span class="string">&#x27;Polygon&#x27;</span>].<span class="title function_">concat</span>(</span><br><span class="line">  styles[<span class="string">&#x27;LineString&#x27;</span>],</span><br><span class="line">  styles[<span class="string">&#x27;Point&#x27;</span>]</span><br><span class="line">);</span><br></pre></td></tr></table></figure>
<h2 id="构造方法"><a href="#构造方法" class="headerlink" title="构造方法"></a>构造方法</h2><table>
<thead>
<tr>
<th>参数名称</th>
<th>参数类型</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td><code>geometry</code></td>
<td>string|Geometry|GeometryFuntion|undefined</td>
<td>该参数可以是：<strong>要素属性</strong>或<strong>几何图形</strong>或是一个<strong>返回此样式渲染的几何体函数</strong>。</td>
</tr>
<tr>
<td><code>fill</code></td>
<td>Fill|undefined</td>
<td>填充样式</td>
</tr>
<tr>
<td><code>image</code></td>
<td>ImageStyle|undefined</td>
<td>Image 样式，<code>ImageStyle</code> 用于创建子类，而不是在应用程序中实例化。<code>Icon</code>、<code>CircleStyle</code>和<code>RegularShape</code>的基类。</td>
</tr>
<tr>
<td><code>renderer</code></td>
<td>RenderFunction | undefined</td>
<td><strong>自定义渲染器</strong>。配置后，填充、描边和Image 样式将被忽略，并且<strong>提供的函数将在每个几何体的每个渲染帧中调用</strong>。</td>
</tr>
<tr>
<td><code>hitDetectionRenderer</code></td>
<td>RenderFunction | undefined</td>
<td>用于命中检测的自定义渲染器。如果提供，将用于命中检测渲染。</td>
</tr>
<tr>
<td><code>stroke</code></td>
<td>Stroke | undefined</td>
<td>描边样式</td>
</tr>
<tr>
<td><code>text</code></td>
<td>Text | undefined</td>
<td>文本样式</td>
</tr>
<tr>
<td><code>zIndex</code></td>
<td>number | undefined</td>
<td>z 索引值</td>
</tr>
</tbody></table>
<h2 id="方法"><a href="#方法" class="headerlink" title="方法"></a>方法</h2><h3 id="clone"><a href="#clone" class="headerlink" title="clone"></a>clone</h3><p><code>clone() =&gt; &#123;Style&#125;</code></p>
<p>克隆样式。</p>
<p><strong>返回值：</strong>克隆的样式。</p>
<hr>
<h3 id="getFill"><a href="#getFill" class="headerlink" title="getFill"></a>getFill</h3><p><code>getFill() =&gt; &#123;Fill | null&#125;</code></p>
<p>获取填充样式。</p>
<p><strong>返回值：</strong>填充样式。</p>
<h3 id="getGeometry"><a href="#getGeometry" class="headerlink" title="getGeometry"></a>getGeometry</h3><p><code>getGeometry() =&gt; &#123;string | Geometry | GeometryFunction | null&#125;</code></p>
<p>获取要渲染的几何体。</p>
<p><strong>返回值：</strong>返回将要素属性或几何图形或使用此样式渲染的几何图形的函数。</p>
<hr>
<h3 id="getGeometryFunction"><a href="#getGeometryFunction" class="headerlink" title="getGeometryFunction"></a>getGeometryFunction</h3><p><code>getGeometryFunction() =&gt; &#123;GeometryFunction&#125;</code></p>
<p>获取用于渲染的几何图形的函数。</p>
<p><strong>返回值：</strong>使用要素调用的函数，并返回要渲染的几何图形而不是要素的几何图形。</p>
<hr>
<h3 id="getHitDetectionRenderer"><a href="#getHitDetectionRenderer" class="headerlink" title="getHitDetectionRenderer"></a>getHitDetectionRenderer</h3><p><code>getHitDetectionRenderer() =&gt; &#123;RenderFunction | null&#125;</code></p>
<p>获取使用<code>setHitDetectionRenderer()</code>方法或<code>hitDetectionRenderer</code>构造函数选项配置的自定义渲染器函数。</p>
<p><strong>返回值：</strong>自定义的渲染器函数。</p>
<hr>
<h3 id="getImage"><a href="#getImage" class="headerlink" title="getImage"></a>getImage</h3><p><code>getImage() =&gt; &#123;ImageStyle | null&#125;</code></p>
<p>获取 Image 样式。</p>
<p><strong>返回值：</strong>Image 样式。</p>
<hr>
<h3 id="getRenderer"><a href="#getRenderer" class="headerlink" title="getRenderer"></a>getRenderer</h3><p><code>getRenderer() =&gt; &#123;RenderFunction | null&#125;</code></p>
<p>获取使用<code>setRenderer</code>或构造函数的<code>renderer</code>选项配置的自定义渲染器函数。</p>
<p><strong>返回值：</strong>自定义的渲染器函数。</p>
<hr>
<h3 id="getStroke"><a href="#getStroke" class="headerlink" title="getStroke"></a>getStroke</h3><p><code>getStroke() =&gt; &#123;Stroke | null&#125;</code></p>
<p>获取描边样式。</p>
<p><strong>返回值：</strong>描边样式。</p>
<hr>
<h3 id="getText"><a href="#getText" class="headerlink" title="getText"></a>getText</h3><p><code>getText() =&gt; &#123;Text | null&#125;</code></p>
<p>获取文本样式。</p>
<p><strong>返回值：</strong>文本样式。</p>
<hr>
<h3 id="getZIndex"><a href="#getZIndex" class="headerlink" title="getZIndex"></a>getZIndex</h3><p><code>getZIndex() =&gt; &#123;number | undefined&#125;</code></p>
<p>获取此样式的<code>z-index</code>值。</p>
<p><strong>返回值：</strong><code>z-index</code>值。</p>
<hr>
<h3 id="setFill"><a href="#setFill" class="headerlink" title="setFill"></a>setFill</h3><p><code>setFill(fill)</code></p>
<p>设置填充样式。</p>
<table>
<thead>
<tr>
<th>参数名称</th>
<th>参数类型</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td><code>fill</code></td>
<td>Fill | null</td>
<td>填充样式。</td>
</tr>
</tbody></table>
<hr>
<h3 id="setGeometry"><a href="#setGeometry" class="headerlink" title="setGeometry"></a>setGeometry</h3><p><code>setGeometry(geometry)</code></p>
<p>设置要渲染的几何图形，而不是要素的几何图形。</p>
<table>
<thead>
<tr>
<th>参数名称</th>
<th>参数类型</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td><code>geometry</code></td>
<td>string|Geometry|GeometryFuntion</td>
<td>要素属性或几何图形或是一个返回此样式渲染的几何体函数。</td>
</tr>
</tbody></table>
<hr>
<h3 id="setHitDetectionRenderer"><a href="#setHitDetectionRenderer" class="headerlink" title="setHitDetectionRenderer"></a>setHitDetectionRenderer</h3><p><code>setHitDetectionRenderer(renderer)</code></p>
<p>为命中检测中使用的此样式设置自定义渲染器函数。</p>
<table>
<thead>
<tr>
<th>参数名称</th>
<th>参数类型</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td><code>renderer</code></td>
<td>RenderFunction |null</td>
<td>自定义渲染器函数。</td>
</tr>
</tbody></table>
<hr>
<h3 id="setImage"><a href="#setImage" class="headerlink" title="setImage"></a>setImage</h3><p><code>setImage(image)</code></p>
<p>设置Image 样式。</p>
<table>
<thead>
<tr>
<th>参数名称</th>
<th>参数类型</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td><code>image</code></td>
<td>ImageStyle</td>
<td>Image 样式。</td>
</tr>
</tbody></table>
<hr>
<h3 id="setRenderer"><a href="#setRenderer" class="headerlink" title="setRenderer"></a>setRenderer</h3><p><code>setRenderer(renderer)</code></p>
<p>为此样式设置自定义渲染器函数。配置后，填充、描边和 Image 样式将被忽略。</p>
<table>
<thead>
<tr>
<th>参数名称</th>
<th>参数类型</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td><code>renderer</code></td>
<td>RenderFunction |null</td>
<td>自定义渲染器函数。</td>
</tr>
</tbody></table>
<hr>
<h3 id="setStroke"><a href="#setStroke" class="headerlink" title="setStroke"></a>setStroke</h3><p><code>setStroke(stroke)</code></p>
<p>设置描边样式。</p>
<table>
<thead>
<tr>
<th>参数名称</th>
<th>参数类型</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td><code>stroke</code></td>
<td>Stroke |null</td>
<td>描边样式。</td>
</tr>
</tbody></table>
<hr>
<h3 id="setText"><a href="#setText" class="headerlink" title="setText"></a>setText</h3><p><code>setText(text)</code></p>
<p>设置文本样式。</p>
<table>
<thead>
<tr>
<th>参数名称</th>
<th>参数类型</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td><code>text</code></td>
<td>Text</td>
<td>文本样式。</td>
</tr>
</tbody></table>
<hr>
<h3 id="setZIndex"><a href="#setZIndex" class="headerlink" title="setZIndex"></a>setZIndex</h3><p><code>setZIndex(zIndex)</code></p>
<p>设置文本样式。</p>
<table>
<thead>
<tr>
<th>参数名称</th>
<th>参数类型</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td><code>zIndex</code></td>
<td>number | undefined</td>
<td><code>z-index</code>值。</td>
</tr>
</tbody></table>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="https://lovewhoilove.gitee.io">lovewhoilove</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://lovewhoilove.gitee.io/posts/965064e3/">https://lovewhoilove.gitee.io/posts/965064e3/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://lovewhoilove.gitee.io" target="_blank">lovewhoilove 的小站</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/Openlayers-API/">Openlayers API</a></div><div class="post_share"><div class="addtoany"><div class="a2a_kit a2a_kit_size_32 a2a_default_style"><a class="a2a_button_wechat"></a><a class="a2a_button_sina_weibo"></a><a class="a2a_button_qzone"></a><a class="a2a_button_douban"></a><a class="a2a_button_print"></a><a class="a2a_button_copy_link"></a><a class="a2a_dd" target="_blank" rel="noopener" href="https://www.addtoany.com/share"></a></div></div><script async="async" src="https://static.addtoany.com/menu/page.js"></script></div></div><div class="post-reward"><div class="reward-button"><i class="fas fa-qrcode"></i> 打赏</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="/img/wechat.jpg" target="_blank"><img class="post-qr-code-img" src= "/img/friend_404.gif" data-lazy-src="/img/wechat.jpg" alt="微信"/></a><div class="post-qr-code-desc">微信</div></li><li class="reward-item"><a href="/img/alipay.jpg" target="_blank"><img class="post-qr-code-img" src= "/img/friend_404.gif" data-lazy-src="/img/alipay.jpg" alt="支付宝"/></a><div class="post-qr-code-desc">支付宝</div></li></ul></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-full"><a href="/posts/b0659e71/" title="OGC矢量切片(地理)【译】"><img class="cover" src= "/img/friend_404.gif" data-lazy-src="https://u-1303826255.cos.ap-nanjing.myqcloud.com/openlayers/202304212152162.jpg?imageMogr2/quality/75/format/webp/interlace/0" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">OGC矢量切片(地理)【译】</div></div></a></div></nav><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div class="vcomment" id="vcomment"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#ol-x2F-style-x2F-Style-Style"><span class="toc-number">1.</span> <span class="toc-text">ol&#x2F;style&#x2F;Style~Style</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%BB%98%E8%AE%A4%E6%A0%B7%E5%BC%8F"><span class="toc-number">2.</span> <span class="toc-text">默认样式</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%9E%84%E9%80%A0%E6%96%B9%E6%B3%95"><span class="toc-number">3.</span> <span class="toc-text">构造方法</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%96%B9%E6%B3%95"><span class="toc-number">4.</span> <span class="toc-text">方法</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#clone"><span class="toc-number">4.1.</span> <span class="toc-text">clone</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#getFill"><span class="toc-number">4.2.</span> <span class="toc-text">getFill</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#getGeometry"><span class="toc-number">4.3.</span> <span class="toc-text">getGeometry</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#getGeometryFunction"><span class="toc-number">4.4.</span> <span class="toc-text">getGeometryFunction</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#getHitDetectionRenderer"><span class="toc-number">4.5.</span> <span class="toc-text">getHitDetectionRenderer</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#getImage"><span class="toc-number">4.6.</span> <span class="toc-text">getImage</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#getRenderer"><span class="toc-number">4.7.</span> <span class="toc-text">getRenderer</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#getStroke"><span class="toc-number">4.8.</span> <span class="toc-text">getStroke</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#getText"><span class="toc-number">4.9.</span> <span class="toc-text">getText</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#getZIndex"><span class="toc-number">4.10.</span> <span class="toc-text">getZIndex</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#setFill"><span class="toc-number">4.11.</span> <span class="toc-text">setFill</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#setGeometry"><span class="toc-number">4.12.</span> <span class="toc-text">setGeometry</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#setHitDetectionRenderer"><span class="toc-number">4.13.</span> <span class="toc-text">setHitDetectionRenderer</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#setImage"><span class="toc-number">4.14.</span> <span class="toc-text">setImage</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#setRenderer"><span class="toc-number">4.15.</span> <span class="toc-text">setRenderer</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#setStroke"><span class="toc-number">4.16.</span> <span class="toc-text">setStroke</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#setText"><span class="toc-number">4.17.</span> <span class="toc-text">setText</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#setZIndex"><span class="toc-number">4.18.</span> <span class="toc-text">setZIndex</span></a></li></ol></li></ol></div></div></div></div></main><footer id="footer" style="background-image: url('https://u-1303826255.cos.ap-nanjing.myqcloud.com/openlayers/202403232115680.png?imageMogr2/quality/75/format/webp/interlace/0')"><div id="footer-wrap"><div class="copyright">&copy;2022 - 2024 <i style="color:red" class="fa fa-heartbeat fa-beat"></i> By lovewhoilove</div><div class="footer_custom_text">生活原本沉闷，但跑起来就有风🎈</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"></div><div id="rightside-config-show"><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><a class="icon-V hidden" onclick="switchNightMode()" title="浅色和深色模式转换"><svg width="25" height="25" viewBox="0 0 1024 1024"><use id="modeicon" xlink:href="#icon-moon"></use></svg></a><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button><button id="go-down" type="button" title="直达底部" onclick="btf.scrollToDest(document.body.scrollHeight, 500)"><i class="fas fa-arrow-down"></i></button></div></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script>function panguFn () {
  if (typeof pangu === 'object') pangu.autoSpacingPage()
  else {
    getScript('https://cdn.jsdelivr.net/npm/pangu/dist/browser/pangu.min.js')
      .then(() => {
        pangu.autoSpacingPage()
      })
  }
}

function panguInit () {
  if (false){
    GLOBAL_CONFIG_SITE.isPost && panguFn()
  } else {
    panguFn()
  }
}

document.addEventListener('DOMContentLoaded', panguInit)</script><script src="/js/search/local-search.js"></script><div class="js-pjax"><script>(() => {
  const $mermaidWrap = document.querySelectorAll('#article-container .mermaid-wrap')
  if ($mermaidWrap.length) {
    window.runMermaid = () => {
      window.loadMermaid = true
      const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'default'

      Array.from($mermaidWrap).forEach((item, index) => {
        const mermaidSrc = item.firstElementChild
        const mermaidThemeConfig = '%%{init:{ \'theme\':\'' + theme + '\'}}%%\n'
        const mermaidID = 'mermaid-' + index
        const mermaidDefinition = mermaidThemeConfig + mermaidSrc.textContent
        mermaid.mermaidAPI.render(mermaidID, mermaidDefinition, (svgCode) => {
          mermaidSrc.insertAdjacentHTML('afterend', svgCode)
        })
      })
    }

    const loadMermaid = () => {
      window.loadMermaid ? runMermaid() : getScript('https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js').then(runMermaid)
    }

    window.pjax ? loadMermaid() : document.addEventListener('DOMContentLoaded', loadMermaid)
  }
})()</script><script>function loadValine () {
  function initValine () {
    const valine = new Valine(Object.assign({
      el: '#vcomment',
      appId: 's2D3RXeuiTBrJjXpdIo4bJuK-gzGzoHsz',
      appKey: 'e6j6L6lA50bj18TlkcZEMw0O',
      avatar: 'monsterid',
      serverURLs: '',
      emojiMaps: "",
      path: window.location.pathname,
      visitor: false
    }, {"placeholder":"畅所欲言哈😁~~"}))
  }

  if (typeof Valine === 'function') initValine() 
  else getScript('https://cdn.jsdelivr.net/npm/valine/dist/Valine.min.js').then(initValine)
}

if ('Valine' === 'Valine' || !true) {
  if (true) btf.loadComment(document.getElementById('vcomment'),loadValine)
  else setTimeout(loadValine, 0)
} else {
  function loadOtherComment () {
    loadValine()
  }
}</script></div><script src="/js/sun_moon.js"></script><script src="/js/jquery.min.js"></script><script data-pjax defer src="/js/chocolate.js"></script><script defer type="text/javascript" src="/js/sweetalert2.all.js"></script><script defer src="/js/lunar.js"></script><script defer src="/js/day.js"></script><script data-pjax defer src="/js/fishes.js"></script><canvas id="universe"></canvas><script src="/js/universe.js"></script><script defer="defer" id="fluttering_ribbon" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-fluttering-ribbon.min.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = true;
POWERMODE.mobile = false;
document.body.addEventListener('input', POWERMODE);
</script><script id="click-heart" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/click-heart.min.js" async="async" mobile="false"></script><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/metingjs/dist/Meting.min.js"></script><script src="https://cdn.jsdelivr.net/npm/pjax/pjax.min.js"></script><script>let pjaxSelectors = ["head > title","#config-diff","#body-wrap","#rightside-config-hide","#rightside-config-show",".js-pjax"]

var pjax = new Pjax({
  elements: 'a:not([target="_blank"])',
  selectors: pjaxSelectors,
  cacheBust: false,
  analytics: false,
  scrollRestoration: false
})

document.addEventListener('pjax:send', function () {

  // removeEventListener scroll 
  window.tocScrollFn && window.removeEventListener('scroll', window.tocScrollFn)
  window.scrollCollect && window.removeEventListener('scroll', scrollCollect)

  document.getElementById('rightside').style.cssText = "opacity: ''; transform: ''"
  
  if (window.aplayers) {
    for (let i = 0; i < window.aplayers.length; i++) {
      if (!window.aplayers[i].options.fixed) {
        window.aplayers[i].destroy()
      }
    }
  }

  typeof typed === 'object' && typed.destroy()

  //reset readmode
  const $bodyClassList = document.body.classList
  $bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')

  typeof disqusjs === 'object' && disqusjs.destroy()
})

document.addEventListener('pjax:complete', function () {
  window.refreshFn()

  document.querySelectorAll('script[data-pjax]').forEach(item => {
    const newScript = document.createElement('script')
    const content = item.text || item.textContent || item.innerHTML || ""
    Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
    newScript.appendChild(document.createTextNode(content))
    item.parentNode.replaceChild(newScript, item)
  })

  GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()

  typeof chatBtnFn === 'function' && chatBtnFn()
  typeof panguInit === 'function' && panguInit()

  // google analytics
  typeof gtag === 'function' && gtag('config', '', {'page_path': window.location.pathname});

  // baidu analytics
  typeof _hmt === 'object' && _hmt.push(['_trackPageview',window.location.pathname]);

  typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting()

  // prismjs
  typeof Prism === 'object' && Prism.highlightAll()
})

document.addEventListener('pjax:error', (e) => {
  if (e.request.status === 404) {
    pjax.loadUrl('/404.html')
  }
})</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><!-- hexo injector body_end start --><div class="js-pjax"><script async="async">var arr = document.getElementsByClassName('recent-post-item');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__zoomIn');
    arr[i].setAttribute('data-wow-duration', '2s');
    arr[i].setAttribute('data-wow-delay', '1s');
    arr[i].setAttribute('data-wow-offset', '100');
    arr[i].setAttribute('data-wow-iteration', '1');
  }</script><script async="async">var arr = document.getElementsByClassName('card-widget');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__zoomIn');
    arr[i].setAttribute('data-wow-duration', '');
    arr[i].setAttribute('data-wow-delay', '');
    arr[i].setAttribute('data-wow-offset', '');
    arr[i].setAttribute('data-wow-iteration', '');
  }</script></div><script defer src="https://npm.elemecdn.com/hexo-butterfly-wowjs/lib/wow.min.js"></script><script defer src="https://npm.elemecdn.com/hexo-butterfly-wowjs/lib/wow_init.js"></script><!-- hexo injector body_end end --></body></html>